clear;
D = dlmread('Toy2.txt');
C = D(:,3);
S = [D(:, 1:2) ones(size(D,1),1)];
b = onlineperceptron(10, 3, polykernel(4));
mist = 0;
for i=1:size(S,1)
mist = mist + b.train(S(i,:), C(i));
end
res = 0;
for i=1:size(S,1)
res = res + b.predict(S(i,:)) - C(i);
end
res

[X,Y] = meshgrid(0:.01:1, 0:.01:1);                                
TS=[reshape(X,numel(X),1) reshape(Y,numel(Y),1) ones(numel(X),1)];
TC = b.predict(TS);
hold on;
c0ind = find(TC > 0);
c1ind = find(TC < 0);
plot(TS(c0ind,1),TS(c0ind,2), 'r.', TS(c1ind,1),TS(c1ind,2), 'g.');
c0ind = find(C > 0);
c1ind = find(C < 0);
plot(S(c0ind,1),S(c0ind,2), 'bo', S(c1ind,1),S(c1ind,2), 'yo');

hold off;